package com.cq.androidtools.jetpack.hilt

import android.app.Activity
import android.app.Application
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import javax.inject.Inject

/**
 * 作者: CQ
 * 日期: 2021-06-25
 * 说明:
 */
class Truck @Inject constructor(val driver: Driver) {

    fun deliver(){
        println("Truck is delivering cargo")
    }
    fun deliverDriver(){
        println("Truck is delivering cargo. Driven by $driver")
    }

    fun show(){
        println("Truck is delivering show. Driven by $driver")
    }

    @Inject
    lateinit var truckInterface: TruckInterface


    @Inject
    lateinit var truckIml: TruckIml

    fun showTruckInterface(){
        truckInterface.onPrint()
        truckIml.onPrint()
        truckIml.onPrints()
    }
}

interface TruckInterface{
    fun onPrint()
}

class TruckIml @Inject constructor() : TruckInterface {
    override fun onPrint() {
        println("onPrint")
    }

    fun onPrints(){
        println("onPrints")
    }
}

@Module
@InstallIn(ActivityComponent::class)
abstract class TruckUser{
    @Binds
    abstract fun bindTruck(truckIml: TruckIml) : TruckInterface
}

class Driver @Inject constructor() {

}

class DriverIml @Inject constructor(val application: MyApplication) {

}
class DriverIml1 @Inject constructor(val application: Application) {

}

class DriverIml2 @Inject constructor(val activity: Activity) {

}